<?php

namespace App\Http\Controllers\Api;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\BaseConfig;
use App\Models\Car;
use App\Models\CarService;
use Illuminate\Http\Request;
use Modules\Car\Entities\CarOrder;
use Modules\Car\Entities\RecognizeDrivingLicense;

//精选服务
class TestController extends Controller
{
    use ResponseData;
    public function test(Request $request,Car $model){
        $data = $model->query()->select('id','pic')->get();
        //$this->replace($data,$model,'page.ywbtzc.com');
       // $this->replace($data,$model,'zc.ywbtzc.com');
       // $this->replace($data,$model,'btpage.oss-cn-hangzhou.aliyuncs.com');
       // $this->replace($data,$model,'page.wisdomcms.com');
        return $this->success('更新成功');
    }
    public function replace($data,$model,$search){
        $arr = [];
        if($data){
            foreach ($data as $v){
                if($v->pic){
                    $pic = str_replace($search,"btzc.oss-cn-hangzhou.aliyuncs.com",$v->pic);
                    $model->where('id',$v->id)->update(['pic'=>$pic]);
                    $arr[] = $pic;
                }
            }
        }
    }
}
